package org.tulkas.robot.patch;

import org.htmlparser.Attribute;
import org.htmlparser.Node;
import org.htmlparser.Tag;
import org.htmlparser.filters.HasAttributeFilter;

/**
 * @author <a href="mailto:tulkas.web@gmail.com">Tulkas</a>
 *
 */
public class HasAttributeICFilter extends HasAttributeFilter {

	private static final long serialVersionUID = 3424126425147435279L;

	public HasAttributeICFilter(String attribute, String value) {
		super(attribute, value);
	}

	@Override
	public boolean accept(Node node) {
		Tag tag;
		Attribute attribute;
		boolean ret;

		ret = false;
		if (node instanceof Tag) {
			tag = (Tag) node;
			attribute = tag.getAttributeEx(mAttribute);
			ret = null != attribute;
			if (ret && (null != mValue))
				ret = mValue.equalsIgnoreCase(attribute.getValue());
		}

		return (ret);
	}

}
